<?php
use backend\assets\AgentAsset;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\LinkPager;

AgentAsset::register($this);
?>
<div class="hide"><iframe name='send_post' id='send_post'></iframe></div>
<div class="mg20-y" style="padding-left: 16px;">
	<form action="<?=Url::toRoute(['financial/cashier'])?>" method="get">
	<input type="hidden" name="action" value='healthcardrefund' />
    <input class="lh45 mr20" type="text" placeholder="输入疗程卡名称" style="width: 224px;height: 42px;line-height: 42px;" name="title" value="<?=\Yii::$app->request->get('title')?>"/>
    <span class="btnBg " style=" height: 40px;">
			<input type="submit"  value="搜索" style="height: 40px;line-height: 40px; background: 0; border: 0; "/>
    </span>
    </form>
</div>
<div class="row">
    <?php if(empty($list)){?>
    <table class="table table-bordered">
        <thead>
        <tr>
            <th>疗程卡名称</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td colspan="1" align="center"><img src="<?=Yii::getAlias('@web/backend/img/nodata.gif');?>"></td>
        </tr>
        </tbody>
    </table>
    <?php }else{?>
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>疗程卡名称</th>
            </tr>
        </thead>

        <tbody>
            <?php foreach($list as $r):?>
            <tr>
                <td><span><?=Html::encode($r['card_name'])?></span>（<em><?=Html::encode($r['remain_times'])?>/<?=Html::encode($r['total_times'])?></em>次）<input type="hidden" name="id" value="<?=$r['card_id']?>"></td>
            </tr>
			<?php endforeach;?>
        </tbody>
    </table>
    <?php }?>
    <div class="page" style="text-align:center;">
                   <?=LinkPager::widget([   
					    'pagination' => $page,
						'firstPageLabel' => '首页',
						'nextPageLabel' => '下一页',
						'prevPageLabel' => '上一页',
						'lastPageLabel' => '末页',
					    'hideOnSinglePage'=>false
					]); ?>
                </div>
</div>
<?php $this->beginBlock('js_index_end') ?>
$(function(){
$('.table tr').dblclick(function(){
var $this = $(this);
$this.find('input[type="text"]').removeClass('read-only').removeAttr('readonly');
$this.find('.fadeBox').show();
$this.find('.editBtn').hide()
})
$('.rest').click(function(e){
e.stopPropagation();
$(this).parent().hide();
$(this).parent().parent().find('.editBtn').show();
$(this).parent().parent().parent().find('input[type="text"]').addClass('read-only').attr('readonly',true);
})

$('.editBtn').click(function(e){
e.stopPropagation();
$(this).hide();
$(this).next().show();
$(this).parent().parent().find('input[type="text"]').removeClass('read-only').removeAttr('readonly');
})

$('.add-recharge').click(function(e){
e.stopPropagation();
$('.lastTr').show();
})
$('.restb').click(function(e){
e.stopPropagation();
$('.lastTr').hide();
})
$('.lastTr input').click(function(e){
e.stopPropagation();
})
})

<?php $this->endBlock() ?>
<?php $this->registerJs($this->blocks['js_index_end'], $this::POS_END); ?>

<?php $this->registerJsFile("@web/system/financial/refund/healthcardrefund.js",['position'=>$this::POS_END]);?>


